<template>
	<div class="changeshop">
	    <div class="modal-backdrop" @click="close">
        <div class="modal"  @click.stop>
          <div class="modal-header">
                <slot name="header">
                <h3 class="title">请选择</h3>
                <div class="close" @click="close">x</div>
                </slot>
            </div>
            <div class="modal-body"> 
                <slot name="body">
                	<div class="store">
                		<h3 v-for="item in shopList" @click="shop(item)">
                			{{item.shopName}}
                		</h3>                		
                	</div>
                </slot>
            </div>            
        </div>
    </div>
	</div>
</template>

<script>
export default {
	name: 'changeshop',
	data() {
		return {
			shopList:[]
		}
	},
	mounted() {
	   this.getShopList()  
	   console.log(this.shopList)
	},
	methods: {
		//店铺接口
		getShopList () {
			this.$http.get(this.$store.state.reqUrl + '/shops/info', {}).then(res => {
			if(res.status == 200) {
				this.shopList = res.data;				
			  }
		   })
				/*this.$http.get(this.$store.state.reqUrl + '/shops/info', {}).then(res => {	
			   	  this.shopList = res.data;
			   	  console.log(res)
		    })	*/	
		},	
		//关闭模态框
		close() {
			this.$emit('close',false);
		},
		shop (item) {
			this.$emit("chooseShop",item);
			this.$emit('close',false);
		}
	}
}
</script>

<style scoped>
	  .modal-backdrop {
	  	position: absolute;
	  	top: 0;
	  	right: 0;
	  	bottom: 0;
	  	left: 0;
	  	z-index: 88;
	  	background-color: rgba(0, 0, 0, .3);
	  	display: flex;
	  	justify-content: center;
	  	align-items: center;
	  }
	  
	  .modal {
	  	background-color: #fff;
	  	box-shadow: 2px 2px 20px 1px;
	  	border-top-right-radius: 22px;
	  	border-top-left-radius: 22px;
	  	overflow-x: auto;
	  	display: flex;
	  	flex-direction: column;
	  	position: fixed;
	  	top:200px;
	  	bottom: 0;
	  	left: 0;
	  	right: 0;
	  	width: 100%;
	  }
	  
	  .modal-header {
	  	display: flex;
	  	width: 100%;
	  	height:100px;
	  	border-bottom: 1px solid gainsboro;
	  	background: #FFFFFF;
	  	position: fixed;
	  	left: 0;
	  	z-index: 88;
	  }
	  
	  .title {
	  	flex: 1;
	  	text-align: center;
	  	line-height: 100px;
	  	font-size: 28px;
	  }
	  
	  .close {
	  	position: absolute;
	  	right: 35px;
	  	font-size: 44px;
	  	line-height: 100px;
	  	color: dimgrey;
	  }
	  
	  .modal-body {
	  	overflow-y: auto;
	  	margin-top: 120px;
	  }
	  
	  .store {
	  	margin-left: 15px;
	  }
	  
	  .store h3 {
	  	margin-bottom: 30px;
	  	line-height: 45px;
	  	font-size: 28px;
	  }
</style>